<div>
    <span class="brand" style="font-weight:bold;">{{flowRuleDialog.title}}</span>
    <div class="card" style="margin-top: 20px;margin-bottom: 10px;">
        <div class="panel-body">
            <div class="row">
                <form class="form-horizontal" role="form">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">资源名</label>
                        <div class="col-sm-9">
                            <input class="form-control" disabled="" ng-if="flowRuleDialog.type == 'edit'"
                                   ng-model='currentRule.resource' placeholder="资源名"
                                   type="text"/>
                            <input class="form-control highlight-border" ng-if="flowRuleDialog.type == 'add'"
                                   ng-model='currentRule.resource' placeholder="资源名"
                                   type="text"
                            />
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label" data-toggle="tooltip"
                               title="流控针对的来源，即流量入口的调用来源（origin）">针对来源</label>
                        <div class="col-sm-9">
                            <input class="form-control highlight-border" ng-model='currentRule.limitApp' placeholder='调用来源，"default"表示所有应用'
                                   type="text"
                            />
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">阈值类型</label>
                        <div class="col-sm-4">
                            <div align="center" class="form-control highlight-border">
                                <input checked name="grade" ng-model='currentRule.grade' type="radio" value="1"/>&nbsp;QPS&nbsp;&nbsp;
                                <input name="grade" ng-model='currentRule.grade' type="radio" value="0"/>&nbsp;并发线程数
                            </div>
                        </div>
                        <div ng-if="!currentRule.clusterMode">
                            <label class="col-sm-2 control-label">单机阈值</label>
                            <div class="col-sm-3">
                                <input class="form-control highlight-border" min="0" ng-model='currentRule.count'
                                       placeholder="单机阈值" type='number'/>
                            </div>
                        </div>
                        <div ng-if="currentRule.clusterMode && currentRule.clusterConfig.thresholdType == 0">
                            <label class="col-sm-2 control-label">均摊阈值</label>
                            <div class="col-sm-3">
                                <input class="form-control highlight-border" min="0" ng-model='currentRule.count'
                                       placeholder="单机均摊阈值" type='number'/>
                            </div>
                        </div>
                        <div ng-if="currentRule.clusterMode && currentRule.clusterConfig.thresholdType == 1">
                            <label class="col-sm-2 control-label">集群阈值</label>
                            <div class="col-sm-3">
                                <input class="form-control highlight-border" min="0" ng-model='currentRule.count'
                                       placeholder="集群总体阈值" type='number'/>
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">是否集群</label>
                        <div class="col-sm-2">
                            <label class="checkbox-inline">
                                <input name="clusterMode" ng-model="currentRule.clusterMode" type="checkbox">
                            </label>
                        </div>
                        <div ng-if="currentRule.clusterMode">
                            <label class="col-sm-3 control-label">集群阈值模式</label>
                            <div class="col-sm-4">
                                <div align="center" class="form-control highlight-border">
                                    <input name="clusterThresholdType" ng-model='currentRule.clusterConfig.thresholdType' type="radio"
                                           value="0"/>&nbsp;单机均摊&nbsp;&nbsp;
                                    <input name="clusterThresholdType" ng-model='currentRule.clusterConfig.thresholdType' type="radio"
                                           value="1"/>&nbsp;总体阈值
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="form-group" ng-if="currentRule.clusterMode">
                        <label class="col-sm-2 control-label">失败退化</label>
                        <div class="col-sm-8">
                            <label class="checkbox-inline">
                                <input name="fallbackToLocalWhenFail" ng-model="currentRule.clusterConfig.fallbackToLocalWhenFail"
                                       type="checkbox">
                                <i class="glyphicon glyphicon-info-sign"></i>&nbsp;如果 Token Server 不可用是否退化到单机限流
                            </label>
                        </div>
                    </div>

                    <div ng-if="!flowRuleDialog.showAdvanceButton && !currentRule.clusterMode">
                        <div class="form-group">
                            <label class="col-sm-2 control-label" title="调用关系流控模式">流控模式</label>
                            <div class="col-sm-9">
                                <div align="center" class="form-control highlight-border">
                                    <input name="strategyEnum" ng-model='currentRule.strategyEnum' type="radio" value="0"/>&nbsp;直接&nbsp;&nbsp;
                                    <input name="strategyEnum" ng-model='currentRule.strategyEnum' type="radio" value="1"/>&nbsp;关联&nbsp;&nbsp;
                                    <input name="strategyEnum" ng-model='currentRule.strategyEnum' type="radio" value="2"/>&nbsp;链路&nbsp;&nbsp;
                                </div>
                            </div>
                        </div>

                        <div class="form-group" ng-show="currentRule.strategyEnum==1">
                            <label class="col-sm-2 control-label">关联资源</label>
                            <div class="col-sm-9">
                                <input class="form-control highlight-border" ng-model='currentRule.refResource' placeholder="关联资源"
                                       type="text"/>
                            </div>
                        </div>
                        <div class="form-group" ng-show="currentRule.strategyEnum==2">
                            <label class="col-sm-2 control-label">入口资源</label>
                            <div class="col-sm-9">
                                <input class="form-control highlight-border" ng-model='currentRule.refResource' placeholder="入口资源"
                                       type="text"/>
                            </div>
                        </div>
                    </div>
                    <div ng-if="currentRule.grade==1 && !flowRuleDialog.showAdvanceButton && !currentRule.clusterMode">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">流控效果</label>
                            <div class="col-sm-9">
                                <div align="center" class="form-control highlight-border">
                                    <input checked name="controlBehavior" ng-model='currentRule.controlBehavior' type="radio"
                                           value="0"/>&nbsp;快速失败&nbsp;&nbsp;
                                    <input name="controlBehavior" ng-model='currentRule.controlBehavior' type="radio"
                                           value="1"/>&nbsp;Warm Up&nbsp;&nbsp;
                                    <input name="controlBehavior" ng-model='currentRule.controlBehavior' type="radio"
                                           value="2"/>&nbsp;排队等待
                                </div>
                            </div>

                        </div>
                        <div class="form-group">
                            <div ng-if="currentRule.controlBehavior==1">
                                <label class="col-sm-2 control-label">预热时长</label>
                                <div class="col-sm-9">
                                    <input class="form-control highlight-border" ng-model='currentRule.warmUpPeriodSec'
                                           placeholder="秒" type='number'/>
                                </div>
                            </div>
                            <div ng-if="currentRule.controlBehavior==2">
                                <label class="col-sm-2 control-label">超时时间</label>
                                <div class="col-sm-9">
                                    <input class="form-control highlight-border" ng-model='currentRule.maxQueueingTimeMs'
                                           placeholder="毫秒" type='number'/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group text-center" ng-if="!currentRule.clusterMode">
                        <a ng-click="onOpenAdvanceClick()" ng-if="flowRuleDialog.showAdvanceButton"
                           style="cursor: pointer;">高级选项</a>
                        <a ng-click="onCloseAdvanceClick()" ng-if="!flowRuleDialog.showAdvanceButton"
                           style="cursor: pointer;">关闭高级选项</a>
                    </div>
                </form>
            </div>
            <div class="separator"></div>
            <div clss="row" style="margin-top: 20px;">
                <button class="btn btn-outline-danger"
                        ng-click="closeThisDialog()"
                        style="float:right; height: 30px;font-size: 12px;margin-left: 10px;">取消
                </button>
                <button class="btn btn-outline-success"
                        ng-click="saveRule()" style="float:right; height: 30px;font-size: 12px;margin-left: 10px;">
                    {{flowRuleDialog.confirmBtnText}}
                </button>
                <button class="btn btn-default" ng-click="saveRuleAndContinue()"
                        ng-if="flowRuleDialog.saveAndContinueBtnText"
                        style="float:right; height: 30px;font-size: 12px;">{{flowRuleDialog.saveAndContinueBtnText}}
                </button>
            </div>
        </div>
    </div>
</div>